package com.lk.springboot.dao;

import com.lk.springboot.vo.Index;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author lk
 * @date 2020/1/10 0010 16:04
 */
@Mapper
public interface IndexMapper {

    @Select("select scores from users where u_id=#{u_id}")
    int getScore(String u_id);

    @Select("select s_id,count(s_id)sp_num from u_s_have where u_id=#{u_id} group by s_id ")
    List<Index> getSmallPhoos(String u_id);

    // 打开主页，签到一次，签到任务进度改变*
    @Update(" update  u_t_solve set speed=1 where u_id=#{u_id} and t_id='t10001' and speed < 999 ")
    void signChange(String u_id);

    // 获取已激活站点数量
    @Select("select  count(DISTINCT s_id)   from u_s_have where u_id=#{u_id}")
    int getUserSitesNum(String u_id);

    // 获取 曾经激活过了 的站点数目
    @Select("select  count(p_id) from user_active_sites where u_id=#{u_id} and active = 1 ")
    int getUserSitesNumED(String u_id);

    // 获取用户已获得所有能用于兑换的站点
    @Select("select s_id from ((select s_id from u_s_have where u_id=#{u_id}  group by sp_id ) as a  ) group by a.s_id having count(a.s_id)=4")
    List<String> getAllokSP(String u_id);

    // 获取用户魔法市场已经抽奖的次数
    @Select("select market_times from users where u_id = #{u_id} ")
    int getMarketTimes(String u_id);
}
